from HGMSim.HGMSimModelWrapper import HGMSimModelWrapper

from EasySample import EasySample
import torch
import json


class experimentRes:
    """
    用来生成对比试验数据的模型
    """

    def __init__(self, modelName, indicators, pairInf, pairName, indicatorsValue):
        """
        输入:
            加载最佳模型
            训练指标
            训练数据集+训练数据集名称
            训练指标参数
        """
        with open("config.json", "r") as file:
            self.config = json.load(file)
        self.bestModelPath = self.config["model"]["bestModelPath"]
        self.modelSample = EasySample()
        self.modelName = self.config["model"]["modelName"]
        self.model = None
        self.modelTrainer = None
        self.get_best_model(modelName)

    def get_best_model(self, modelName):
        """
        加载模型的最佳参数------>model
        部分模型需要加载Trainer--->modelTrain
        """
        if modelName == "HGMSim":
            self.model = torch.load(self.bestModelPath)
            self.modelTrainer = HGMSimModelWrapper(self.model)
